function initbody(){
	xcy.init();
}

var xcy = {
	init:function(){
		this.resiezess();
		this.touchobj = $('#mainbody').rockdoupull({
			downbool:true,scrollbool:false,
			ondownsuccess:function(){
				xcy.reload('none');
			},
			ondownbefore:function(){
				return xcy.index==0;
			}
		});
		this.reload();
	},
	index:0,
	otherheight:65,
	changetab:function(tab, bo){
		if(tab==1){
			js.location('?d=we&m=index&a=word');
			return;
		}
		if(this.index==tab)return;
		$('#tabzhu'+this.index+'').removeClass('weui-bar__item_on');
		$('#tabzhu'+tab+'').addClass('weui-bar__item_on');
		$('#m_index'+this.index+'').hide();
		$('#m_index'+tab+'').show();
		this.index=tab;
		js.setoption('nowindex', tab);
		if(bo)return false;
		return false;
	},
	getheight:function(ss){
		if(!ss)ss=0;
		var hei = this.otherheight;
		if(get('header'))hei+=50;
		return winHb()-hei+ss;
	},
	resiezess:function(){
		var hei = xcy.getheight();
		$('#mainbody').css('height',''+hei+'px');
		viewheight = hei;
	},
	loginout:function(bo){
		if(bo){
			js.loading('退出中...');
			js.ajax({
				url:'api.php?m=index&a=exit',
				success:function(){
					js.msgok('退出成功');
					js.location('?d=we&m=login');
				}
			});
			return;
		}
		js.confirm('确定要退出吗？',function(jg){
			if(jg=='yes'){
				xcy.loginout(true);
			}
		});
	},
	reload:function(bo){
		js.ajax({
			url:'api.php?m=index&a=data',
			success:function(ret){
				$('#indexload').remove();
				$('#m_index0').show();
				if(!ret.success){
					js.msgerror(ret.msg);return;
				}
				xcy.loadshow(ret.data);
			},
			dataType:'json'
		});
	},
	loadshow:function(da){
		this.touchobj.ondownok();
		this.shownewfile(da.newfile);
	},
	shownewfile:function(da){
		var str='',i,col,d,fsts;
		for(i=0;i<da.length;i++){
			col = '';
			d = da[i];
			if(!isempt(d.thumbpath)){
				fsts= '<img src="'+js.fileuppath(d.thumbpath)+'" onclick="js.viewimg(this)" width="20" height="20" align="absmiddle">';
			}else{
				var lxs = js.filelxext(d.fileext);
				fsts= '<img src="'+FILE_URL+'images/fileicons/'+lxs+'.gif"  height="20" align="absmiddle">';
			}
			str+='<div class="weui-cell"><div class="weui-cell__bd"><p>'+fsts+' '+d.filename+' <span style="font-size:12px;color:#aaaaaa">('+d.optdt+')</span> <a href="javascript:;" onclick="js.fileopt(\''+d.filenum+'\',0)">[预览]</a></p></div></div>';
		}
		$('#newfilediv').html(str);
	}
}